Public Class Frm_Siparis

    Private Sub Frm_Siparis_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UzakServis.Timeout = 99999
        UzakServis.Url = Servis_Url
        Dim cls As New Cls_Database

        If ProgramTipi = 0 Then
            cls._ProgramID = Cls_Database.Program.MikroV10
        Else
            cls._ProgramID = Cls_Database.Program.MikroV12
        End If

        Dim dt As New DataTable
        cls._Bilgi = Cls_Database.Tip.SiparisListe
        dt = cls.GetData
        dt.TableName = "SIPARIS"
        DataGridView1.DataSource = dt

        DataGridView1.Columns(0).Visible = False
        DataGridView1.Columns(0).ReadOnly = True
        DataGridView1.Columns(1).ReadOnly = True

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim stokkod As String = ""
        Dim miktar As Decimal = 0
        Dim envanter As Decimal = 0
        Dim str_sql As String = ""
        Dim tarih As String = Now.Year & "-" & Now.Month & "-" & Now.Day

        UzakServis.FillDataSet(Sql_Server, Database_Name, "DELETE FROM SMARTOFFICE_SIPARIS where depo=" & Depo_Kod & " and (tarih = CONVERT(DATETIME, '" & tarih & " 00:00:00', 102))")

        For i As Integer = 0 To DataGridView1.RowCount - 1
            stokkod = DataGridView1(0, i).Value
            miktar = DataGridView1(2, i).Value
            If miktar = Nothing Then miktar = 0
            envanter = DataGridView1(3, i).Value
            If envanter = Nothing Then envanter = 0
            str_sql = "INSERT INTO SMARTOFFICE_SIPARIS  (tarih,depo, stokkod, miktar, envanter) VALUES     ('" & tarih & "'," & Depo_Kod & ", '" & stokkod & "', " & miktar & ", " & envanter & ")"
            UzakServis.FillDataSet(Sql_Server, Database_Name, str_sql)
        Next
    End Sub
End Class